<?php

class CodeController extends BaseController
{
    protected $project;

    public function preAction()
    {
        parent::preAction();

        $this->view->assign('tree', Docgroup::getPackageTree());

        $name = $this->getParam('project');
        $this->project = Project::getByParams(array('name' => $name));
        if (!$this->project) {
            Url::redirect('/projects/');
        }

        $this->view->assign('project', $this->project);
    }

    public function defaultAction()
    {
        $this->view->assign('nav', array('Проект ' . $this->project->title => '/projects/view/' . $this->project->name,
                                         'Інспектор коду' => '/project/' . $this->project->name . '/code/'));

        $tree = DocSourceFolder::getTreeByProject($this->project);

        $this->view->assign('code_tree', $tree);

        $this->view->display('code.default.tpl');
    }
}